package cn.ggy.dao;

import cn.ggy.polo.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AccountDaoImpl implements AccountDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void updateAccount(Account account) {
        String sql = "update account set money = money-? where id =?";
        jdbcTemplate.update(sql,account.getMoney(),account.getId());
    }

    @Override
    public void updateAccount2(Account account) {
        String sql = "update account set money = money+? where id =?";
        jdbcTemplate.update(sql,account.getMoney(),account.getId());
    }
}
